﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MovieRental_Presentation.DataViews;
using MovieRental.EnhancedEntities;

namespace MovieRental_Presentation
{
	public partial class Dashboard
	{
        private DashboardDataView _dataView;

		public Dashboard()
		{
			this.InitializeComponent();

			// Insert code required on object creation below this point.
            Loaded += delegate
            {
                Window w = Window.GetWindow(this);
                w.MinHeight = this.MinHeight + 50;
                w.MinWidth = this.MinWidth + 20;
            };

            _dataView = new DashboardDataView();
            DataContext = _dataView;
            _dataView.SelectedDate = DateTime.Today;
		}

		private void customersButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			this.NavigationService.Navigate(new Customers());
		}

		private void moviesButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			this.NavigationService.Navigate(new Movies());
		}

	
		private void statisticsButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			this.NavigationService.Navigate(new Statistics());
		}

        private void ListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
        	// TODO: Add event handler implementation here.
        }

        private void cartsListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
        	if (cartsListBox.SelectedIndex != -1)
			{
				Guid customerId = (cartsListBox.SelectedItem as LoanCart).Entity.CustomerId;
				NavigationService.Navigate(new CustomerDetails(customerId));	
			}
        }

        private void searchTextBox_Search(object sender, System.Windows.RoutedEventArgs e)
        {
        	_dataView.SearchString = searchTextBox.Text;
        }

	}
}